/* PRE-PLUGINS SECTION */
var do_PrePlugins = function() {
    // your customized code is here
    // Channel Manager Parameter config

    // pageName
    if (!s.pageType && !s.pageName) {
        s.pageName = s.getPageName();
        if (s.pageName) s.pageName = s.pageName.replace(/\.[a-z]+$/, "").replace(":index", "");
        if (s.pageName.indexOf("rms:nid:vc") > -1) s.pageName = "login-old";
    }

    //channel
    if (!s.channel) {
        s.channel = s.pageName.split(":")[0];
    }

    var registStep, registType, gePageName;
    registStep = s.getTagValById('geRegistStep');
    registType = s.getTagValById('geRegistType');
    gePageName = s.getTagValById('gePageName');

    switch (registStep) {
        case "registration:start":
            s.pageName = "Member: Regist Step1 " + registType;
            break;
        case "registration:confirm":
            s.pageName = "Member: Regist Step2 " + registType;
            break;
        case "registration:complete":
            s.pageName = "Member: Regist Finish " + registType;
            break;
    }
    if (gePageName) {
        s.pageName = gePageName;
        s.channel = gePageName.split(':')[0];
    }

    if (s.pageName == "logout") {
        s.channel = "logout";
    } else if (s.pageName.indexOf("login") > -1) {
        s.channel = "login";
        if (s.events) {
            s.events += ",event6";
        } else {
            s.events = "event6";
        }
        s.eVar2 = s.getQueryParam("service_id");
        s.prop4 = s.getPreviousValue("login_" + s.eVar2, "gpv");
    } else if (s.pageName.indexOf("Member: Regist") > -1) {
        s.channel = "member_regist";
        if (s.pageName == "Member: Regist Insert") {
            if (s.events) {
                s.events += ",event14";
            } else {
                s.events = "event14";
            }
        }
        if (s.pageName == "Member: Regist Finish Normal") {
            if (s.events) {
                s.events += ",event15";
            } else {
                s.events = "event15";
            }
        }
        s.eVar1 = s.getQueryParam("service_id");
        if (s.pageName == "Member: Regist Finish Relay") {
            if (s.events) {
                s.events += ",event16";
            } else {
                s.events = "event16";
            }
        }
        if (s.getQueryParam("xbp") == "1") {
            s.pageName += " nonjp";
        }
    }

    if (s.server == "r10.to") {
        s.pageType = "errorPage";
        s.prop1 = 'D="404:"+server';
    }
    //member - non-member
    if (s.server.indexOf("rakuten.co.jp") > 0) {
        s.prop13 = s.getCk("Rq") ? "member" : "non-member";
    }

    s.prop3 = "D=r";
    s.prop28 = s.eVar28 = s.getTimeParting("d") + s.getTimeParting("h");
    s.prop47 = s.deviceName();

    //Adding UI info from <meta name="viewport">
    if (s.getUiInfo() === "SP") {
        s.pageName += "[smart]";
        s.channel += "[smart]";
    }
    //RakutenPageType
    if (s.RakutenPageType && (typeof s.eo == "undefined")) {
        s.pageName += "[" + s.RakutenPageType + "]";
        s.channel += "[" + s.RakutenPageType + "]";
    }
};

/* POST-PLUGINS SECTION */
var do_PostPlugins = function() {
    // your customized code is here
    if (s.getQueryParam("service_id")) {
        s.prop2 = "[" + s.getQueryParam("service_id") + "]" + s.pageName;
    } else {
        s.prop2 = s.pageName;
    }
    // for MST global tracking
    if (!s.eo && !s.lnk && !s.pageType && !s.un.match(/dev/) && !s.un.match(/rakutenglobal/)) {
        if (s.campaign.match(/_gmx/) || s.campaign.match(/_upc/) || s.eVar49) {
            s.un = s.apl(s.un, "rakutenglobalprod");
        }
    }
    try {
        dTime = new Date();
        dTime.setYear(dTime.getYear() - 1);
        var ckArry = new Array("s_ppv", "s_xuse", "s_gpv-pn", "rwdd_pv", "pnt_pn", "brd_cvp1", "shs_pn", "shs_ch", "gpv_ch", "gpv_pn", "s_vnum", "s_invisit", "bks_cvp", "gpv");
        for (i = 0; i <= ckArry.length - 1; i++) {
            if (ckArry[i]) {
                s.setCk(ckArry[i], "", dTime.toGMTString());
            }
        }
    } catch (e) {}
};

/* CUSTOM-PLUGIN SECTION */


/* CODE SECTION - DON'T TOUCH BELOW */
if (s.usePrePlugins) s.doPrePlugins = do_PrePlugins;
if (s.usePostPlugins) s.doPostPlugins = do_PostPlugins;

/************* To Stop Google Preview From Being Counted *************/
if (navigator.userAgent.match(/Google Web Preview/i)) {
    s.t = new Function();
    s.tl = new Function();
}

// s_code abolish

s.t = function () {
    return false;
}

s.tl = function () {
    return false;
}
